namespace DotNetNuke.HttpModules
{
    using DotNetNuke.Services.Log.EventLog;
    using System;
    using System.Web;

    public class ExceptionModule : IHttpModule
    {
        public void Dispose()
        {
        }

        public void Init(HttpApplication application)
        {
            application.Error += new EventHandler(this.OnErrorRequest);
        }

        public void OnErrorRequest(object s, EventArgs e)
        {
            HttpServerUtility Server = ((HttpApplication) s).Context.Server;
            Exception lex = new Exception("Unhandled Error: ", Server.GetLastError());
            new ExceptionLogController().AddLog(lex);
        }

        public string ModuleName
        {
            get
            {
                return "ExceptionModule";
            }
        }
    }
}

